package weapons;

import java.awt.Color;

import java.awt.Shape;
import java.awt.geom.Ellipse2D;
import java.awt.geom.QuadCurve2D.Double;

import graphics.MaxGraphics;
import main.Game;
import ship.Ship;
import structure.SObject;
import util.Point;

public class StaticMine extends Mine {

	private int staticRadius = 300;
	private int counter = 500;

	public StaticMine(Ship s) {
		super(s);
		exploded = false;
		range = 300;
	}

	@Override
	public void draw(MaxGraphics g) {
		if(! exploded) {
			g.setColor(Color.magenta);
			g.fillOval(getX(), getY(), 5, 5);
		}
		else {
			int j = 0;
			g.translate(getX(), getY());
			for(int i = -staticRadius; i < staticRadius; i++) {
				for(j = -staticRadius; j< staticRadius; j++) {
					if(Math.sqrt(i*i + j*j) < staticRadius) {
						double color = Math.random();
						g.setColor(new Color((float) color, (float) color, (float) color));
						g.drawRect(i, j, 1, 1);
					}
				}
			}
			g.translate(-getX(), -getY());
		}
	}

	public void update(){
		if(exploded) {
			counter--;
			if(counter == 0) {
				flag();
			}
		}
		super.update();
	}

	@Override
	public double getRadius() {
		// TODO Auto-generated method stub
		return 5;
	}

	@Override
	public Shape[] getShape() {
		Shape[] s = { new Ellipse2D.Double(getX() - (range/2), getY() - (range/2), range, range) };
		return s;
	}

	@Override
	public void explode() {
		exploded = true;

	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return null;
	}

	public double getMass() {
		return .1;
	}


}

